import { defineConfig } from 'vite'
import { createVuePlugin } from 'vite-plugin-vue2'
import { fileURLToPath, URL } from "node:url";
// import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import Unocss from 'unocss/vite'
import legacy from '@vitejs/plugin-legacy'


// https://vitejs.dev/config/
export default defineConfig(async () => ({
  plugins: [
  //  legacy({
  //     targets: ['defaults', 'not IE 11'],
  //   }),
    createVuePlugin({
      // include: ['.vue','.jsx','.js'],
      jsx: true
    }),

    Components({
      dirs: ['./src/components'],

      // valid file extensions for components.
      extensions: ['vue'],
      // globs: ['src/components/*.{vue}'],
    }),
    Unocss()
  ],
  resolve: {
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
    alias:{
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    }
  },
  clearScreen: false,
  
  // 2. tauri expects a fixed port, fail if that port is not available
  server: {
    port: 1420,
    strictPort: true,
    watch: {
      // 3. tell vite to ignore watching `src-tauri`
      ignored: ["**/src-tauri/**"],
    },
  },
  build: {
    // sourcemap: 'inline',
    rollupOptions:{
     /* sourcemap: 'inline',
      output:{
        sourcemap: 'inline'
      }*/
    }
  },
  optimizeDeps : {
    needsInterop: ['vue-loading-template']
  }
}));


